import express from 'express'
import sha1 from 'sha1'
const router = express.Router();

router.get('/', (req, res, next)=>{
     
      let signature = req.query.signature;
      let timestamp	= req.query.timestamp;
      let nonce	= req.query.nonce;
      let token = 'liwei';
      let echostr = req.query.echostr;
      console.log(signature,'-',timestamp,'-',nonce,'-',echostr);
      let str = [token, timestamp, nonce].sort().join('');
      let sha = sha1(str);
      
      console.log('sha',sha);
      if(sha===signature){
           console.log('successful');
           res.send(echostr+'')

      }else{
           console.log('fail');
           res.send('err'); 
      }

});

export default router;